#include "MyTcpServer.h"

MyTcpServer::MyTcpServer(QObject *parent)
	: QTcpServer(parent)
{}

MyTcpServer::~MyTcpServer()
{}

void MyTcpServer::incomingConnection(qintptr socketDescriptor)
{
	QThread *myThread = new QThread;												//线程对象
	ClientHandler *myClienthandler = new ClientHandler(socketDescriptor);			//事件对象
	myClienthandler->moveToThread(myThread);
	myThread->start();
	QObject::connect(this, &MyTcpServer::signal_to_thread, myClienthandler, &ClientHandler::working);
	QObject::connect(myClienthandler, &ClientHandler::setMsg, this, &MyTcpServer::getMsg);
	emit signal_to_thread();
}

void MyTcpServer::getMsg(QString strMsg, QString strIp, QString strPort)
{
	emit signal_to_showMsg(strMsg, strIp, strPort);
}
